package com.custom.action.joiner.interfaces;

import com.custom.comm.utils.lambda.SFunction;

import java.io.Serializable;

/**
 * @author Xiao-Bai
 * @since 2023/4/30 19:05
 */
@SuppressWarnings("all")
public interface SqlFunction<Children> extends Serializable {

    /**
     * groupBy函数
     * @param params 字段列
     * @return Children
     */
    <Any> Children groupBy(SFunction<Any,?>... columns);


    /**
     * having函数
     * @param havingSql havingSql
     * @param params 参数值 ? -> value
     * @return Children
     */
    Children having(boolean condition, String havingSql, Object... params);
    default Children having(String havingSql, Object... params) {
        return having(true, havingSql, params);
    }

    /**
     *  limit分页
     * @param pageIndex 第几页
     * @param pageSize 每页的记录数量
     * @return
     */
    Children pageParams(Integer pageIndex, Integer pageSize);


    <Any> Children orderByAsc(boolean condition, SFunction<Any,?>... columns);
    default <Any> Children orderByAsc(SFunction<Any,?>... columns) {
        return orderByAsc(true, columns);
    }

    <Any> Children orderByDesc(boolean condition, SFunction<Any,?>... columns);
    default <Any> Children orderByDesc(SFunction<Any,?>... columns) {
        return orderByDesc(true, columns);
    }



    <Any> Children orderByAsc(boolean condition, SFunction<Any,?> column);
    default <Any> Children orderByAsc(SFunction<Any,?> column) {
        return orderByAsc(true, column);
    }

    <Any> Children orderByDesc(boolean condition, SFunction<Any,?> column);
    default <Any> Children orderByDesc(SFunction<Any,?> column) {
        return orderByDesc(true, column);
    }


}
